
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 2
 * @Author : WangRuoyu 
 * @Date : 2023/5/16 17:34
 */

#include "iostream"

using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string str;
        cin >> str;
        char op[3];
        int nums[4];

        for (int j = 0; j < str.size(); ++j) {
            if (j % 2) op[j / 2] = str[j];
            else nums[j / 2] = str[j] - '0';
        }
        int cnt = 3;
        for (int j = 0; j < cnt; ++j) {
            if (op[j] == 'x') {
                cnt--;
                nums[j] = nums[j] * nums[j + 1];
                for (int k = j; k < cnt; ++k) {
                    op[k] = op[k + 1];
                    nums[k + 1] = nums[k + 2];
                }
                j--;
            } else if (op[j] == '/') {
                cnt--;
                nums[j] = nums[j] / nums[j + 1];
                for (int k = j; k < cnt; ++k) {
                    op[k] = op[k + 1];
                    nums[k + 1] = nums[k + 2];
                }
                j--;
            }
        }
        if (cnt != 0) {
            for (int j = 0; j < cnt; ++j) {
                if (op[j] == '+') {
                    cnt--;
                    nums[j] = nums[j] + nums[j + 1];
                    for (int k = j; k < cnt; ++k) {
                        op[k] = op[k + 1];
                        nums[k + 1] = nums[k + 2];
                    }
                    j--;
                } else if (op[j] == '-') {
                    cnt--;
                    nums[j] = nums[j] - nums[j + 1];
                    for (int k = j; k < cnt; ++k) {
                        op[k] = op[k + 1];
                        nums[k + 1] = nums[k + 2];
                    }
                    j--;
                }
            }
        }
        if (nums[0] == 24) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}